package com.mlh.springboot.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author 缪林辉
 * @date 2024/3/3 16:18
 * @DESCRIPTION
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler({ArithmeticException.class,NullPointerException.class})
    public String handleArithmeticException(Exception e, Model model){
        log.error("异常：{}",e);
        model.addAttribute("msg", e.getMessage());
        return "/error/global";
    }
}
